package com.xiu.timer;

import java.util.Timer;
import java.util.TimerTask;

public class TestTimer {
	public static void main(String[] args) {
		System.out.println("About to schedule task.");
		new Reminder(3);
		System.out.println("Task scheduled.");
	}

	public static class Reminder {
		Timer timer;

		public Reminder(int sec) {
			timer.schedule(new TimerTask() {

				@Override
				public void run() {
					System.out.println("time is up");
					timer.cancel();
				}
			}, sec);
		}
	}
}
